<template>
    <div>
        <el-table :data="tableData" border stripe style="width: 100%">
            <el-table-column fixed type="index" label="序号" width="50" align="center" :index="indexMethod"></el-table-column>
            <el-table-column fixed prop="ProjectName" label="日期" align="center" >
                <template slot-scope="slot">
                    {{ fmtDate(slot.row.JournalDate) }}
                </template>
            </el-table-column>
            <el-table-column fixed prop="Team" label="班组" align="center" ></el-table-column>
            <el-table-column fixed prop="Weather" label="天气状况" align="center" ></el-table-column>
            <el-table-column fixed prop="WindPower" label="风力" align="center" ></el-table-column>
            <el-table-column fixed prop="MaxTemperature" label="最高温度" align="center" ></el-table-column>
            <el-table-column fixed prop="MinTemperature" label="最低温度" align="center" ></el-table-column>
            <el-table-column fixed prop="ConstructionCondition" label="施工日志" align="center" ></el-table-column>
            <el-table-column fixed prop="WorkRecord" label="工作记录" align="center" ></el-table-column>
            <el-table-column fixed label="操作" align="center" width="120"> 
                <template slot-scope="slot">
                    <el-button type="success" size="mini" plain @click="ShowProjectLogTable(slot.row)">报表</el-button>
                </template>
            </el-table-column>
        </el-table>

        <el-dialog :visible.sync="ProjectLogTableTwo_dialog.show" :fullscreen="true" title="日志报表" :modal="false">
            <ProjectLogTableTwo :project="project" :project-journal="ProjectLogTableTwo_dialog.data"></ProjectLogTableTwo>
        </el-dialog>
    </div>
</template>

<script>
    import ProjectLogTableTwo from "./ProjectLogTableTwo";

    export default {
        name: "ProjectLogTable",
        components:{
            ProjectLogTableTwo
        },
        props:{
            project:{
                type:Object,
                required:true,
            }
        },
        data(){
            return{
                tableData:[],
                ProjectLogTableTwo_dialog:{
                    show:false,
                    data:{},
                },
            }
        },
        watch:{
            project:function () {
                this.GetData()
            }
        },
        mounted() {
            let _this = this
            this.$nextTick(()=>{
                _this.GetData()
            })
        },
        methods:{
            //表格数据序列号
            indexMethod(index) {
                return index + 1
            },
            //数据转换
            fmtDate(val){
                if (val!=null&&val!=''){
                    return val.split(' ')[0]
                }else{
                    return ''
                }
            },
            //数据获取
            GetData(){
                this.$http.post('Project1/GetAllProjectJournalData',{ ProjectId: this.project.Id }).then(res=>{
                    console.log(res.data)
                    this.tableData = res.data;
                })
            },
            //报表弹框
            ShowProjectLogTable(obj){
                this.ProjectLogTableTwo_dialog.show=true
                this.ProjectLogTableTwo_dialog.data=obj
            }
        }
    }
</script>

<style scoped>

</style>
